Variable oscillator for generating different frequencies in a controller area network (CAN)

ABSTRACT

A device suitable for use as a module in a Controller Area Network (CAN) system with a bus or connection includes relatively simple and inexpensive components, including an oscillator that generates a number of different frequencies in response to directions from a microcomputer. A CAN Controller receiving the frequencies is connected to the bus via a transceiver. The device has utility for verification and validation work in association with a CAN system.

BACKGROUND

This disclosure relates to a device that is operationally andfunctionally suitable for inclusion in a module in a (Controller AreaNetwork) CAN system with CAN connection.

Specifying, verifying and validating CAN systems with the object ofobtaining sufficient information to ensure reliable functioningthroughout the whole life of a system is already known. In associationwith this, reference is made to instruments of various kinds that areavailable on the market for analysing CAN buses, for example CANalyzerfrom Vector Informatik GmbH, X-analyser from Warwick Technologies Ltd,and CANlab from Accurate Technologies Inc., all of which are PC-basedsoftware that, in conjunction with various CAN/PC interfaces from KvaserAB, for example LAPcan, can retrieve, timestamp and send messages anderror frames on the bus in order to determine the appearance in relationto time of messages on the bus and if and when errors appear. Inaddition, there are other instruments, for example CAN Scope from VectorInformatik that can measure voltage levels on the CAN bus as a functionof the time and, using the rules of the CAN protocol, can display aninterpreted image in which the voltage levels are displayed as CAN bits.There are also conventional oscilloscopes incorporating correspondinginterpretation. Kvaser markets a product, Memorator, by means of which alarge number of messages can be time stamped and saved for lateranalysis.

A well-known problem is that CAN Controllers (CCs) can only be set tocertain bit times determined by the frequency of the oscillator thatclocks the CC. For example, 1 Mbit/s can not be set at all with a 13 MHzor 33 MHz clock frequency, while with a 12 MHz frequency only the samplepoints 50% and 66.67% can be selected. For data communication ingeneral, oscillators are required with great precision, often 500 ppmdown to 20 ppm. For example, the USB standard demands at least 500 ppmprecision and USB components often demand tighter tolerances, forexample Philips recommends 50 ppm for its ISP1761 USB host controller.The requirement for precision in the CAN standard ISO 11898 is dependentupon Phase_Seg1, Phase_Seg2, SJW, and the bit time. There is thus adifference between the requirement for oscillator precision in a datacommunication system such as USB and a control system such as CAN. Inthe former, the precision is given by the specification, while in thelatter, it is dependent upon the system construction in an individualsystem. In communication between a CAN bus and a computer, thecommunication takes place via an interface. The communication betweenthe interface and the computer often takes place via a serial datacommunication that demands a precise oscillator frequency, for exampleUSB with 12 MHz and 50 ppm.

It is common in known instruments that they do not have a validationfunction, whereby the various respective CAN settings and oscillators ofthe modules connected to a CAN bus can be controlled. There is also aneed for a unit forming a CAN module to be able to be connected to theCAN system and to be used for various target and indication cases and,for example, to be used as the source in the system for interpretationand initiation of various functions in the CAN system. The unit must,for example, be able to be connected as a source of interference in thesystem in association with testing. The unit must be able to be sold asseparate to the CAN module or corresponding individual connectable unit.The unit must also be able to work with components that are constructedand function in a simple way. The unit must be able to work withconnections of various types (topologies), preferably bus connectionsbut also with optical connections, star-wired connections and/or networkconnections.

SUMMARY

In order to solve the basic problem of being able to adapt a CAN modulecontaining a microprocessor to any CAN bit time, an oscillator isintroduced with variable clock frequency that clocks the CC and areference frequency that can be compared with the variable clockfrequency. The source of the reference frequency can be a crystaloscillator or it can be obtained indirectly from messages on the CAN busby measuring how many clock cycles the message takes up from Start OfFrame to the acknowledgement bit and comparing this with a theoreticallyderived value.

There is thus a need for devices that can solve the abovementionedproblem, using their own microcomputer or together with a high-levelcomputer. Embodiments of this disclosure solve all or parts of thisproblem and, in connection with this, indicates new ways of looking atthe CAN bus and its function.

Embodiments in this disclosure work principally with a CC, a CANTransceiver (CT), an oscillator with variable frequency, a CPU withassociated memories and peripherals and a reference frequency. To obtainthe reference frequency indirectly, embodiments of this disclosureutilizes protocol rules according to CAN (ISO 11898-1) and indication ofthe SOF and ACK bits in the CAN messages. In particular, the protocol'srules are utilized for the construction of a CAN message on the bus. Forcertain purposes, one or more counters are also utilized. Thisdisclosure also relates to a method for enabling a module to adjustautomatically to a system's bit rate.

The principal characteristics of a device according to this disclosureare that it comprises an oscillator that, in response to directions froman associated microcomputer, generates a number of different frequenciesand also comprises a CAN Controller utilizing the frequencies that isconnected or can be connected to the connection via a transceiver.

Further developments of the concept of this disclosure are apparent fromthe following subsidiary claims.

In accordance with an embodiment, CAN messages can only occur in CANControllers. A transmitting CAN Controller generates pulses at TTL levelon its TX connection to a CAN transceiver that amplifies these to apulse train on the bus. The CAN transceivers of receiving modules readoff the pulse train on the bus and convert these to pulses at TTL leveland display these on the RX connection of the respective connected CANControllers. The CAN Controller interprets the pulses according to theCAN protocol and determines whether they represent a correct CAN messageor not.

This approach leads to the recognition that it is possible to constructa device with a CAN transceiver, a CAN Controller, a variable oscillatorand a microprocessor as the main components, which among other thingscan generate pulses and pulse trains on the bus and can also analysepulses and pulse trains on the bus according to the rules of the CANprotocol and determine within which limits the pulse train on the buscan be interpreted as correct CAN messages, when Error Flags are to begenerated and when a pulse on the CAN connection is to be disregarded.The new way of thinking is that CAN messages only occur in CANControllers. A transmitting CAN Controller generates pulses at TTL levelon its TX connection to a CAN transceiver that amplifies these to apulse train on the bus. The CAN transceivers of receiving modules readoff the pulse train on the bus and convert these to pulses at TTL leveland display these on the RX connection of the respective connected CANControllers. The CAN Controller interprets the pulses according to theCAN protocol and determines whether they represent a correct CAN messageor not.

This new way of thinking leads to the recognition that it is possible toconstruct a device with a CAN transceiver, a CAN Controller, a variableoscillator and a microprocessor as the main components, which cangenerate varying pulses and pulse trains on a CAN connection in order tostimulate and activate the CC of other modules connected to theconnection and also to analyse pulses and pulse trains on the busaccording to the rules of the CAN protocol and determine within whichlimits the pulse train on the bus can be interpreted as correct CANmessages or Error Flags.

BRIEF DESCRIPTION OF THE DRAWINGS

Embodiments of the disclosure are described below with reference to theattached drawings in which:

FIG. 1 shows the construction of bits and bit segments in a CAN system;

FIG. 2 shows in the form of block diagram the construction of a CANmodule with the new components that can be connected to CAN systems thatcomprise a connection (for example a bus connection) to which other CANmodules are also connected;

FIG. 3 shows in the form of block diagram a second embodiment of a CANmodule with a number of CAN Controllers and transceivers;

FIG. 4 shows in the form of a combined diagram and block diagram bit andstructure configurations;

FIG. 5 shows in the form of a diagram the relationships between bitconfigurations;

FIG. 6 shows in the form of a diagram additional relationships betweenbit constellations;

FIG. 7 shows in the form of block diagram an embodiment that is modifiedin relation to the embodiment according to FIG. 3;

FIG. 8 shows in the form of block diagram an embodiment that is furthermodified in relation to the embodiment according to FIG. 3; and

FIG. 9 shows in the form of block diagram a third embodiment.

DETAILED DESCRIPTION

In order to facilitate the understanding of this disclosure, theconstruction of a CAN bit 100 is shown in FIG. 1. It is constructed of anumber of bit quanta, BTQ, that are generated by an oscillator whosefrequency is broken down by a prescaler and divided into SynchronizationSegment (Sync_Seg), Propagation Segment (Prop_Seg), Phase Segment 1(Phase_Seg 1) and Phase Segment 2 (Phase_Seg 2), or alternatively intoSync_Seg, Time Segment 1 (TSEG_1) and Time Segment 2 (TSEG_2). Accordingto the rules for CAN, the symbol 0 is dominant over 1. In addition, amaximum of five consecutive symbols of the same value can betransmitted, after which at least one symbol of opposite value must betransmitted. If six or more symbols of the same type are to betransmitted, an extra symbol of opposite type is inserted, so-called bitstuffing. For signaling, the Non Return to Zero (NRZ) method is used,that is consecutive symbols of the same value are identified by deadreckoning. A free bus has the continual value 1. A message is introducedby a zero, Start of Frame (SOF). The falling edge on changing from 1 to0 at SOF is utilized for synchronization of all the connected CCs. Theseare then re-synchronized at each falling edge in the following bitsequence in a message. Sync Jump Width (SJW) is the maximum number ofBTQ that can be used for adjusting the bit length duringresynchronization. During resynchronization TSEG_1 is shortened orTSEG_2 is lengthened by the requisite number of BTQ, however at mostSJW. The CAN protocol places requirements on CCs' oscillators connectedto a system. Their frequency f_(osc) must not deviate from a nominalfrequency f_(nom) by more than df according to the following, where allthe conditions must be fulfilled:[(1−df)*f _(nom) .f _(osc). (1+df)*f _(nom)]  1)df. {(Phase_Seg1, Phase_Seg2)_(min)/[2*(13*T _(b)−Phase_Seg2)]}  2)df□(SJW/20*T _(b)), where T _(b) is nominal bit time.  3)

As can be seen from the above, the tolerance requirement for a module'soscillator frequency is dependent upon the CAN Controller's setting andthe current signal delays. For more detailed information refer to ISO11898-1. This disclosure also relates to a method for enabling a moduleto adjust automatically to a system's bit rate.

FIG. 2 schematically shows an embodiment. The object of device 202 andalso one or more modules 203, 204 that are active on the bus areconnected to a CAN connection 201. This embodiment has a microprocessor205 with requisite peripherals 206 and can be connected via a connection207 to a high-level computer 208, for example a PC, via a USBconnection. The microprocessor is connected to the CAN Controller CC1via the connection 209. The CAN Controller contains a state machine 230that operates according to rules for CAN 231, an error counter 232,transmission logic 233 that generates outgoing pulses, bit time logic234 that, among other things, determines the sample point and bit end, aconfiguration register 235, message queues for incoming 236 and outgoing237 messages, a filter 238, a clock generator 239 and a communicationdevice 240 for communication with the microprocessor. CC1 is clocked bya clock frequency 210, generated by the variable oscillator 211. Usingthe program 243, the microprocessor sets the oscillator's 211 frequencyvia the connection 212 and the setting logic 241. CC1 is connected tothe CAN transceiver CT1 via the transmission connection TX1 and thereception connection RX1. CT1 is connected to the CAN bus 201 via theCAN High connection 213 and the CAN Low connection 214. These are alsoconnected to the AD-transducer 215 that can measure the potential of therespective connections in relation to the earth reference potential 216.The microprocessor can read off the AD-transducer via the connection 217and can thereby not only ascertain the change of level on the bus, butalso measure the deviations in potential of other transmitting modulesrelative to the earth reference 216. Using the program 243, themicroprocessor can also set CT1 in active or listen only mode via theconnection 218. In listen only mode, CC1 signals on TX1 are preventedfrom going out on the bus 201 but are returned to RX1. Themicroprocessor has also one or more clock functions 219 with counter andcapture register 220. Pulse trains 221 appear on the bus. Each suchpulse train 221′ changes between two differential voltage levels, level0 (Level 0) and level 1 (Level 1). CT1 receives a pulse train 221′ anddisplays it on CC1's RX input RX1 at TTL level 220″. The pulse train isnow interpreted by CC1 according to the rules for CAN. The first change242 from level 1 to level 0 is interpreted as SOF if level 0 stillapplies at the sample point, otherwise the change is disregarded. If thelevel after SOF is still 0 at the next sample point, the first bit inthe CAN identifier is recorded as 0. If it changed to level 1, the bitis recorded as 1, and so on. In the event of transmission, CC1 generatesa bit pattern according to the CAN rules, that goes out as a pulse trainon the connection TX1 to CT1 that sends out a corresponding pulse trainon the CAN bus. Now assume that CC1 is set to a bit length that is sixtimes longer than the value set in the modules 203 and 204 and assumethat CC1 is to transmit a message where the CAN identifier startswith 1. CC1 sends out SOF to CT1, which in turn changes the CAN buslevel from 1 to 0. This level persists until CC1 sends out level 1.Meanwhile, modules 203 and 204 CCs have detected a correct SOF followedby five bits with the same symbol 0 which is not in accordance with thebit stuffing rules of the CAN protocol, for which reason they transmitan error flag. It will now be recognized that with the approach that aCC generates and interprets pulse trains on the CAN bus via a CTaccording to its local setting and the rules of the CAN protocol, it ispossible with an apparatus according to the description to generatepulses and pulse trains to a bus with CC1 and CT1 by the application ofthe CAN rules, which pulses and pulse trains are received andinterpreted differently by other modules connected to the bus accordingto the same CAN rules. In addition, by receiving pulse trains from othermodules, it is possible to determine within which setting limits CC1interprets the pulse trains as correct CAN messages according to the CANrules and thereby to ascertain the deviations of the transmitting modulefrom the nominal setting values. For example, the module's 203 samplepoint can be determined in the following way:

1. The modules 204 are disconnected from the bus, or alternativelycontinue in silent mode.

2. Assume that the system's bit frequency is 250 kbit/s and CC1 is setto this with the frequency 16 MHz.

3. The microcontroller 205 sets the oscillator 211 to 21.333 MHz andcommands CC1 to transmit any message in which the CAN identifier startswith 1111.

4. When the microprocessor has indicated SOF, either by the level changebeing measured by the AD-transducer 215 or, if CC1 is of the type thatgenerates an SOF interrupt, upon the reception of such an interrupt, itchanges over CT1 into silent mode and thereafter CC1 receives its ownmessage.

5. A pulse has gone out on the bus that represents 75% of a zeroaccording to the CAN protocol. The CC in 203 has detected a falling edgefrom level 1 to level 0 and, if the level does not persist at the samplepoint, then no action is taken, which is now assumed to be the case.

6. After CC1 has received its own message, this is reported to themicrocontroller and the conclusion can be drawn that the pulse wasshorter than CC's at the 203 sample point.

7 The procedure is repeated from 3 above, but with the frequency 21 MHz.

8. The change now takes place after the sample point and the CC in 203interprets an SOF followed by ones. When six ones have been counted, theCC in 203 transmits an error flag.

9. CC1 receives its own message, but CT1 transmits level 0 from the buson account of the error flag transmitted by the CC in 203.

10. CC1 indicates bit error due to the error flag and reports failure oftransmission to the microprocessor.

11. From what has occurred, it can be ascertained that the sample pointof the CC in 203 lies between 75% and 76.2% of the bit time.

FIG. 3 shows schematically a construction of a CAN module according toan embodiment. A module 302 according to this embodiment is connected tothe CAN bus 301 and one or more other modules connected to the systemare represented by 304. The CAN module consists of a microprocessor 305with requisite peripherals 306. The CAN module can be connected to ahigh-level computer 307, for example a PC, via the connection 308, forexample a USB connection. In the microprocessor arrangement there areone or more clock-functions 309, 309′, each with a counter with one ormore capture registers 310, 310′. The oscillator 303 is of a type withvariable frequency and clocks the clock function 310. A CAN ControllerCC1 is comprised in the microprocessor, or alternatively can beconnected to the microprocessor, which CAN Controller CC1 is alsoclocked by the oscillator 303. The CC is connected to a transceiver CT1in the usual way via the RX and TX connections. The transceiver CT1 hascircuits 340 that interact with the CAN Controller, circuits 341 thatinteract with the CAN connection, circuits 342 that interact with themicroprocessor and logic 343 for, among other things, changing betweenlisten only mode and active mode. The transceiver has, among otherthings, the task of matching levels in the connection to the processinglevels that apply in the processing equipment. Known transceiver typescan be used, for example SN65HVD235D from Texas Instrument. Theoscillator's 303 frequency can be controlled from the microprocessor viathe connections 313. In addition, the microprocessor arrangement isequipped with a temperature sensor 317. The CAN system works with anominal bit frequency, for example 250 kbit/s, which occurs commonly inpractice. The well-known CAN protocol SAEJ1939 works with this bit rate.The oscillator 303 can be a Dallas Maxim DS1086, which has adigitally-set fundamental frequency between 33.3 and 66.6 MHz in rangesof 5.12 MHz. Within each range, the frequency can be set in steps of 5kHz, that is, 1024 steps giving a resolution of approx. 1 per thousand.

Example of bit rates achieved by CC1:

Time resolution Frequency ns/setting MHz Bit rate # BTQ ns/BTQ μs/bitstep 33.300 252.275 22 180.18 3.9639 33.305 252.300 22 180.16 3.9635 0.433.310 252.350 22 180.13 3.9628 0.7 33.315 252.375 22 180.01 3.9624 0.434.000 246.375 23 176.47 4.0589 34.000 250.000 17 235.29 4.000 39.995999.900 20 50.005 1.0001 40.000 1000 20 50 1.000 .1 40.005 1000.1 2049.995 9.999 .1 40.010 1000.2 20 49.990 9.998 .1

The example above shows that it is possible to achieve a time resolutionof parts of a nanosecond in the bit time per setting step and that, withone and the same incoming frequency, it is possible to obtain differentbit times by changing the number of BTQ in the bit. It is thus possibleto utilize an inexpensive variable oscillator as the one proposed forthe generation of bits with small differences between them. However, theproposed oscillator has very wide tolerances, +/−0.5% for the setfundamental frequency and over 3% across the temperature range −40 to+85 C. In order to reduce the effect of these tolerances, a referencefrequency 312 is introduced that can be generated by a crystaloscillator 311 and the temperature sensor 317 is introduced in order tobe able to obtain the current temperature and thereby the ability tocorrect for temperature variations. For certain determined frequencies,there are crystal oscillators with high precision, 50 ppm and below,available at a low cost as they are used in mass-produced apparatusessuch as mobile telephones, computers, clocks, etc. The oscillator 311can advantageously be selected from such a range that the frequency isof lesser importance in comparison to the precision and the cost. Theoscillator 311 clocks the clock function 309′ with the fixed frequency312 that can be broken down into a suitable frequency for the counter310′. In a corresponding way, the variable oscillator 303 is connectedto the clock function 309. The oscillator 303 clocks the CC1. Themicroprocessor 305 can advantageously be clocked by the oscillator 303via the connection 314 if an internal CC is to be used, but can beclocked in another way. The microprocessor 305 sets the oscillator's 303outgoing frequency 315 via the connection 313. The microprocessor 305can read off the current temperature from the temperature sensor 317 viathe connection 316. In addition, data 318 has been stored in themicroprocessor's memory concerning the oscillator's 311 frequency and,if required, also its temperature dependence. In order to improve theprecision of the frequency 315, the frequency 312 is now utilized as thereference frequency according to the following:

The system now consists of an adjustable clock signal 315 with a poorprecision, for example 0.5% and a second fixed clock signal 312 with ahigh precision, for example 20 ppm, that are to be set in relation toeach other so that their mutual relationship is ensured and so that itis thereby possible to calibrate the oscillator 303 to a higherprecision, for example 200 ppm or better. The measurement of a clocksignal can be carried out in two different ways. The direct method is tomeasure the period of the clock signal. However, the period time of a 25MHz clock signal is 40 nanoseconds and a measurement with a precision of0.1% requires a resolution of 4 picoseconds, which is difficult withcurrent technology. The second method is to count the number of clockpulses over a particular period of time and to compare the number ofclock pulses according to the equation:Clock pulses_(—)312/(309′_PulsesPerSecond*309′_measurement period)==Clock pulses_(—)315/(309_PulsesPerSecond*309_measurement period)

If the same measurement period is used for both the frequencies, thesimplified equation is obtained:309_PulsesPerSecond==309′_PulsesPerSecond*(Clock pulses_(—)315 /Clockpulses_(—)312).

How the measurement is carried out depends on which type of counter andperipheral logic the implementation provides and this varies accordingto which type of microprocessor and peripheral logic is available. If,for example, an M32C processor from Renesans is used, then it ispossible to carry out the measurement in the following way.

First it must be ensured that the clocks have a clock frequency thatlies below 10 MHz as the inputs to this processor's counter cannothandle a higher frequency than this. One clock can have a higherfrequency if this is also used to clock the microprocessor, as it canthen be up to 32 MHz. The reference crystal 311 is assumed to have thefrequency 19 MHz. The microprocessor sets the oscillator 303 to 19 MHzvia the connection 313. The clock signal 312 is connected to one of themicroprocessor's clock inputs 321 via the frequency transmitter 320 thathalves the frequency to a permitted 9.5 MHz. By setting special logicfor this input, the signal can be connected to a counter, symbolized by310′, with 16 bits. M32C has additional logic 322 that makes it possibleto restart the counter when a set value has been reached or when thecounter has reached its highest value, hexadecimal FFFF. When this takesplace, the counter logic has a function that means that an input canchange level, that is, a divided-down clock signal is obtained, relativeto the connected clock frequency. This output is thereafter connected toa second counter input 323 on M32C. For this counter, symbolized by 310,the input logic is set so that the signal is used to start and stop thecounter. This counter is set in such a way that it counts the internalclock 324 that is driven by the clock signal 315. When the counter 310′that counts clock signals 312 reaches its change-over point 1′, theoutput in 322 changes over and starts the counting of clock signals thatcome from the clock signal 315 in the counter 310. Thereafter these twocounters count pulses simultaneously. When the first counter has reachedits change-over point 2′, the output changes value and the secondcounter 310 stops. Thereafter the microprocessor can read off the valuein the second counter 1 that can be compared directly with the firstcounter's change-over point from 1′ to 2′. M32C has logic that makes itpossible to rescale the clock pulses 312, by dividing down the frequencybefore it is connected to the second counter. If the resolution is notadequate with this direct measurement, then it is possible to extend themeasurement over a number of the abovementioned measurement periods byusing interrupts and software.

As an alternative to using a crystal oscillator in order to generate areference frequency, a reference frequency can be obtained from the CANbus. In this case, a CC is used that can give a signal upon thedetection of SOF, which the CC MCP2515 from Microchip can do, and inaddition the module's CAN connection can be set to listen only mode,that is can receive messages, but not the signals on the bus. This canbe achieved by the use of a CAN transceiver SN65HVD235D from TexasInstrument. This can be connected in an “autobaud feedback loop” wherebyit forwards incoming signals to the CC's RX input but stops the CC'ssignals from the TX output from coming out on the bus, that is, the sameas listen only mode. With the abovementioned choice of components, CT1can be set in active or listen only mode by the processor 305 via theconnection 330 and CC1 can generate an SOF pulse directly or indirectlyto the clock function 309 or alternatively to the processor 305 via theconnection 331. In the same way, signals on RX1 and TX1 can be connecteddirectly or indirectly to 309 via the connections 332 and 333respectively. The module or modules 304 connected to the CAN bus 301 areassumed to send messages symbolized by 332. The abovementioned referencefrequency device 333 is now not needed. The reference frequency isobtained by the sequence described below. The current bit rate on theCAN bus 301 is assumed to be 250 kbit/s.

1. The microprocessor 305 sets the oscillator 303 to a suitablefrequency for CC1 in order to obtain 250 kbit/s, for example 16 MHz, viathe connection 313.

2. The microprocessor thereafter sets CC1 to the bit length 8 BTQ, 75%sample point, SJW=4 and prescaler=8, via the connection 331.

3. CT1 is set in listen only mode. Comments: With this setting, the CC1is able to compensate for a large deviation between the transmittingCC's oscillator and its own by adjusting its bit time by up to 4 BTQ ateach resynchronization.

4 When the CC1 signals SOF, the counter's 310 value is captured incapture register 1.

4.a Alternatively, the counter 310 captures each value when theconnection 332 exhibits a falling edge in a capture register.

5. The microprocessor reads off and saves the captured value when it hasreceived an SOF indication from CC1.

6. When CT1 signals a falling edge on TX1, which is forwarded to thecounter 310 via the connection 332, the counter's value is captured inthe capture register 2.

7. The microprocessor reads off the captured value one or several clockcycles after a falling edge has been detected on TX1.

8. When CC1 has indicated a received message to the microprocessor, itreads this off and determines, using the rules of the CAN protocol, howmany clock cycles N in 309 this message would have occupied from the SOFsample point, up to the falling edge in ACK,

8.a or alternatively, the falling edge in SOF, up to the falling edge inACK.

9. The microprocessor calculates the value M which is the differencebetween the values captured in the capture register 1 and the captureregister 2 minus the number of pulses corresponding to 6 BTQ (the numberup to the sample point in SOF),

9.a or alternatively minus 0.

10. The microprocessor obtains the reference frequency by dividing N byM.

By means of repeated measurements and calculation of average values formessages with the same CAN identifier, the frequency of a particularmodule on the network can be obtained. By means of measurements ofmessages with different CAN identifiers and calculations of averagevalues, a virtual system frequency can be obtained.

When the oscillator 303 has been calibrated to the reference frequency,it can be set to the correct frequency in order to obtain the correctbit time for the system. Thereafter the CC1 bit-timing register is setto the values specified for the system and is thereafter ready foractive signaling on the bus. The calibration is suitably repeated atdifferent temperatures, after which temperature compensation can becarried out.

Swing

This disclosure thus makes it possible to set a module according to aCAN system specification with any bit time and low frequency deviationusing simple and inexpensive standard components. As mentioned above,the requirement concerning the oscillator tolerance of the individualmodules is dependent upon the system's construction and the CC's settingof bit time and SJW. There is a need to be able to verify and validatethe specification. This can be carried out by utilizing the variableoscillator 303. The tolerance specified in the specification for the CANsystem in question, for example 1%, is used as a starting point. Themicroprocessor is first set to a nominal frequency, for example 16 MHz,and a number of messages, for example 1000 messages, are receivedwithout errors. Thereafter, the microprocessor sets (16*1.05) MHz and ifa number of messages, for example 1000 messages, are received correctly,the upper tolerance limit has been verified for reception. The procedureis repeated with the oscillator setting (16*0.995) MHz and if the samenumber of messages is received correctly, then the whole tolerance rangehas been verified for reception. Thereafter the procedure is repeatedwith the transmission of a corresponding number of messages and if theycan be transmitted without the other modules generating error frames,the tolerance range has been verified. In order to validate thetolerance range, the swing is increased to, for example, +/−1.5% and themicroprocessor steps up the frequency, for example in increments of0.01%, after each 1000th received message. For each increment, thenumber of error frames that CC1 generates is recorded. By logging allvalues in a test vehicle over a long period of time and under extremeconditions, the number of error frames can be compiled as a function ofthe frequency and the limits for the permitted frequency deviation inthe system can be validated.

FIG. 4 shows an alternative embodiment of the device 402 connected to aCAN bus 401 that operates at 250 kbit/s. The module 402 has three setsof CCs, CTs and oscillators and a microprocessor 405 with requisiteperipherals 406. The module is connected to a high-level computer 407,for example a PC, via the connection 408, for example USB. Themicroprocessor arrangement comprises a clock function 409 with a numberof capture registers 410. The oscillator 411 clocks the microprocessorand the clock function. The microprocessor comprises or is connected toa CAN Controller CC1, which is also clocked by the oscillator 211. TheCC is connected to a transceiver TC1 in the usual way via the RX and TXconnections. The first TC can be set in active or passive mode by theprocessor 205 via the connection 214. In the same way, an additional twoCAN Controllers and transceivers are arranged, CC2 and TC2 and CC3 andTC3 respectively. However, these are clocked by the oscillators OSC2 andOSC3 respectively. The frequency of these oscillators can be controlledfrom the microprocessor via the connections 415 and 416 respectively.The oscillators OSC2 and OSC3 are of variable type as described aboveand the oscillator 411 has a fixed frequency. In addition, themicroprocessor arrangement is equipped with one or more timers,symbolized by 417, and a temperature sensor 418.

Active Detection

1. Determination of Sample Point

The sample point of a target module 403 in the system is to bedetermined. Any other connected modules 404 are disconnected or set in amode that ensures that none can signal actively on the bus or transmitan ACK bit or error frame, so-called silent mode. In order to determinethe module's 403 sample point, CC2 is set to 1 Mbit/s with 20 BTQ andOSC2 at 40 MHz. TC1 and CC1 are set in the normal way for communicationwith the bit rate 250 kbit/s. The setting is not critical as CC1 willonly be used for the detection of errors. CC2 is instructed to send amessage with a CAN identifier that starts with 0011111. The remainder ofthe message is not of importance. The target module will perceive 00 asan SOF. Assume that the module had a 16 MHz clock and that it is set to16 BTQ and 75% sample point, that is, 4 BTQ from the end. FIG. 5 showsthe procedure in detail. CC1 transmits the message according to theabove, which is shown by 501. The target module records an SOF andexpects to read a zero according to 502. By increasing the frequency ofOSC2, the pulse is made shorter so that the target module reads a one atthe sample point, which is shown by 503 and 503′. The target module theninterprets the falling edge as an interference and takes no action. Byreducing the frequency of OSC2, the pulse is made longer (504, 504′) andif the target module reads a dominant level, it will then expect zerosand ones, however at the most four consecutive zeros or five consecutiveones according to the rules for CAN. By varying the OSC2 frequency andthereby the pulse so that the target module alternately generates anddoes not generate an error frame within an ever-decreasing range, thesample point of the target module can be calculated with great precisionby indirectly utilizing the CC's ability to send CAN messages. However,it is necessary for signals from CC2 to be prevented from going out onthe bus after the pulse has been generated and CC1 must not be able toread the bus until after the pulse has died away. This is achieved byCT2 being set in active mode and CT1 being disconnected from the busbefore the procedure is started. When CC2 detects it own sample point505 in its own SOF, it triggers the timer 507 by the signal 508. This isset to approximately 7 μs. When the time has expired, the signal 509 isgenerated that disconnects CT2 from the bus and connects in CT1, wherebyCT modes are utilized indirectly by the change-over taking place duringthe course of the CAN signaling. The change-over is shown by 510. Thisresults in CC1 reading the bus as recessive (511) if the pulse isshorter than the sample point of the target system, but if the pulse islonger than the sample point of the target module, then there will be anactive error flag after the target module has detected six recessivebits (512). CC1 will detect this as an SOF (513) and after fiveconsecutive bits it will generate an active error flag 514. This eventgenerates an interrupt 515 to the microprocessor, either or both of theSOF and active error flag being dependent upon the characteristics andsetting of CC1, that thereby has information for indirectly determiningthe sample point of the target module according to the method described.Thus, using CC1, the microprocessor can detect whether the target systemis transmitting an active error flag or not. The error handlingspecified in CAN is used indirectly to measure the sample point.

Improved Precision

In the method described above, the sample point is determined using arising edge. As it is a passive edge, its gradient depends upon thetermination and capacitance of the bus. A falling edge is activelydriven and therefore steeper. Once the sample point is approximatelyknown, its position can be determined with greater precision if afalling edge is input. We now let the CAN identifier of the transmittedmessage start with 0101111 which generates a double pulse 515. Themessage is sent with the same bit rate as before. If no error isdetected, then the sample point 516 of the target module lies at thezero. If an error is detected, the sample point lies at the one, whichis shown by 516′. The sample point is input by increasing the bit timeif an active error flag is generated and by reducing the bit time ifthere is no active error flag. By means of a gradually reducing range,the sample point is determined.

Determination of the Bit Rate of the Target Module

In order to determine the bit rate of the target module, OSC2 and CC2are utilized to generate a pulse that is perceived by the target modulealternately as the introduction to a message with the CAN identifier00001x and as a message with the CAN identifier 00000x where abit-stuffing error arises. FIG. 6 shows such pulses. In the former case,the target module will send an error frame after it has counted fiverecessive bits, while in the latter case, it does so immediately afterit has detected the incorrect bit stuffing bit. This makes it possibleto measure the bit rate of the target system by basically the samemethod as described above for measuring the sample point by indirectutilization of the CAN specification's definition of bit, stuffing bit,message and error handling. When the sample point of the target modulehas been determined, it is possible to obtain a measurement of thehighest possible bit rate which is 25/23-parts of the sampling time. Itcan be expedient to set CC2 and OSC2 to obtain a bit time that is 4/3parts of the measured time. Using the method described above, a pulse isgenerated with the length of five bit times. The pulse 601 has becomelonger than the sum of SOF, four consecutive bits and the time to thesample point S according to the target module's CC, so that thisgenerates an active error flag 602 due to a stuffing error in the nextbit. The pulse 603 is, on the other hand, too short, so the targetmodule's CC reads a one after four zeros. After having read another fourones, it expects a zero 604, but reads a one and so generates an activeerror flag 605. The sample point S of the target module has thus beenlocked in between the pulse lengths T1 and T2. By gradually reducing thedifference between T1 and T2, the time from the falling edge in SOF tothe sample point S can be determined. The bit time T_(bm) of the targetmodule is given by the equationT _(bm)=(5*T _(b) −T _(sm))/5,

where T_(b) is the bit time for CC2 and T_(sm) is the target module'stime to the sample point. As no falling edge has been generated by thepulse, the target module has never been resynchronized.

Determination of SJW

SJW determines the maximum adjustment of the bit time that a receivingmodule can carry out. By setting CC2 to send a message with the CANidentifier starting with eleven ones, it will send out the bit sequence01111101111101, that is the triple pulse 606. By increasing the bit timein CC2, the triple pulse 606′ is achieved. The target module expects theappearance of 607 but as the falling edge does not come untilimmediately before the sample point, it resynchronizes with SJW andexpects the continued pattern 608. At the sample point 609 a zero isexpected but a one is read and so an active error flag 610 is sent out.By shortening the triple pulse time, the target module can receive themessage correctly. In this way, the sampling time 609 has been input andcan be measured indirectly by varying CC2's bit time. When the time T3from SOF to the sample point 609 has been determined, the SJW time canbe obtained by the equationT _(SJW) =T3−(12*T _(bm) +T _(sm))

Determination of Signal Delay

The signal delay between the target module and the measurement modulecan be measured simply in the following way. CC2 is set to send amessage that starts with the CAN identifier 111111x, that is a stuffingbit is necessitated. After the SOF has been generated, CT2 disconnectsTX2 from the bus and the pulse 701 in FIG. 7 is generated. CC3 reads thebus and detects SOF. After six consecutive ones have been read, anactive error flag is generated. The target module does likewise, butlater due to the signal delay. The bit time in CC3 is now lengthened sothat it does not generate an error frame but reads the active error flagas the start of a legal dominant bit. 702 shows how the target modulegenerates an active error flag and 703 shows how CC3 interprets this asa dominant bit. By shortening CC3's bit time, it will detect a stuffingbit error immediately before the change-over from the target module'sactive error flag has reached it. In this way, the falling edge from thetarget module can be delimited. By adjusting CC3's bit length to thechange-over point between immediate error frame generation and afterfive consecutive bits, the falling edge of the target module can bemeasured. The signal delay T_(sjw) can now be obtained from the equationT _(sjw)=(6*T _(b3) +T _(s3))−(6*T _(m) +T _(sm))

where T_(b3) is CC3's bit time and T_(s3) is its sampling time and T_(m)is the target module's bit time and T_(sm) is its sampling time.

Calibration of CC2 and CC3

The methods described above assume that the bit times of CC2 and CC3,that is OSC2 and OSC3, are calibrated against a reference. Theoscillator 211 is used as a reference. CC1 is set for a given bit rate,for example 250 kbit/s and the sample point is set to 75% of the bittime. Using the method that has been described for measuring the targetmodule's bit rate, CC1's bit rate is now measured with CC2 and CC3.Alternatively, CC1's sample point is measured by the method describedand thus a value is obtained directly for the modulating voltages ofOSC2 and OSC3 respectively in order to obtain a bit length for250*0.75=187.5 kbit/s. Each oscillator drifts with the temperature. Thecurrent temperature for the calibration is measured by the temperaturesensor 418. By recalibrating at different temperatures, a temperaturecompensation can be calculated. All measurements can now be carried outwith the oscillator 411 as reference. This can, in turn, be calibratedto an external reference according to the methods described in theSwedish patent applications SE 0401922-0 and SE 0401130-0.

In order to keep the respective CCs in active error mode, a number ofmessages that are perceived as correct can be transmitted occasionallyin order to enable the error counters to count down according to therules of the CAN protocol.

Alternative Construction and Calibration

FIG. 8 shows an alternative construction. The crystal 411 has beenreplaced by a variable oscillator OSC1 that clocks the CPU 405′ and CC1.A reference crystal oscillator 801 of good quality, for example 16 MHzwith 20 ppm precision or 12 MHz and 50 ppm precision, has beenintroduced. Counters 802, 803, 804 and 805 are connected to this and tothe respective OSCs, which counters can all be started and stoppedsimultaneously by the CPU 405′, or alternatively there can be captureregisters that can be frozen simultaneously. The oscillator 801, thatworks with a fixed frequency, can be used to clock peripherals thatpreferably work with a fixed frequency, for example communicationcircuits 806 for the communication with the high-level computer 407′. Bysimultaneously counting the pulses from 801 and the respective OSCs overone and the same time, the frequency of the OSCs can be set in relationto the reference frequency from 801. Thereby the CPU 405′ has a tool forsetting the respective OSCs to any frequency within their frequencyrange with a given precision in relation to the reference frequency 801.In this way, a local time base has been established. Many CPUsincorporate one or more CCs that are clocked with the same basefrequency as the CPU itself. If the base frequency is fixed, this limitsthe possibilities for adapting an incorporated CC to a suitable bit rateand sample point in a CAN system that works with a different fundamentalfrequency. As OSC1 can here be adjusted, an incorporated CC1 can alsoadvantageously be used. The local time base may need to be matched tothe high-level computer 407′. If the communication between 402′ and 407′uses a protocol that is based on synchronous time slots given by thehigh-level computer, for example USB, then its start-of-frame pulse canbe utilized by counting the oscillator's 801 pulses during a timeslot. Achange-over unit 807 is caused by the CPU 405′ to connect in SOF pulsesfrom the USB unit 806 that start and stop the counter 802, oralternatively freeze its capture register. In this way, the number ofpulses that 801 generates during a timeslot is obtained.

Passive Monitoring

The previously-described methods assume that only one target module isconnected at a time and that active signaling can be used. Many timesthis is not possible or desirable. A method of indirectly utilizing thecharacteristics of the CAN controllers and the CAN protocol formeasuring quality can be carried out as described below:

The CC1 in FIG. 4 is set to the system's nominal bit rate. The CC2 isvaried in steps towards a lower bit rate and the CC3 is varied towards ahigher bit rate. Each CC is allocated two capture registers in 409. Thetime is captured at SOF and at the ACK bit or locally generated errorframe. All the CTs are set so that listening on the bus can take place,but not transmission. CC3's output TX3 is connected to capture register1 by the connection 419. When CC3 activates TX3, the time is frozen incapture register 1. In this way, the time is captured for a generatedACK bit or active error flag. The capture register 2 is connected toCC3's SOF signal by the connection 420. In this way, each falling edgeon the bus that CC3 perceives as a SOF is captured. CC1 and CC2 areconnected in a corresponding way to their respective capture registers.After each message detected by CC1 or each error frame generated by CC1,the microprocessor preferably reads off the following values:

Temperature

-   -   For each CC:    -   Time of SOF    -   Time of ACK or error frame    -   TSEG_1 and TSEG_2    -   Prescaler    -   SJW    -   Oscillator frequency    -   The CAN identifier    -   The RTS bit    -   DLC    -   Received bit pattern in the receive buffer    -   TEC    -   REC    -   Error status registers

These are sent to the high-level computer 407 via the connection 408.The high-level computer logs the messages that have been sent. Atpredetermined intervals, for example each second, the high-levelcomputer commands the microprocessor 405 to reduce the bit time by acertain amount, for example 0.1% in CC2 and to increase CC3 by the sameamount. With increased deviation, CC2 and CC3 will generate error framesfor certain messages while CC1 receives a correct message. Utilizing theSOF and ACK time stamps, it can be ascertained whether there is a slotlarger than three bit times between a message and the subsequentmessage. If such is the case, no arbitration and hence noresynchronization has been carried out at the transmitter. By seeing atwhich bit times in CC2 and CC3 error frames start to be generated for agiven CAN identifier, it can be determined by how much the transmittingmodule's bit time deviates in relation to the measurement module. Thebit rate of the transmitting module is the average of CC2's and CC3'sbit rates at which error frames start to appear if CC2 and CC3 have thesame SJW, preferably one BTQ. As each message with DLC differing fromzero has only one sender, the bit rate of each module in the system canbe determined. By continually monitoring a system in this way,variations in the respective modules can be measured and related todifferent operating situations and the limits for serious interferencecan be extrapolated.

Determination of Message Length

The length of a CAN message varies with the transmitting module'soscillator frequency and setting, resynchronization upon arbitration andthe number of stuffing bits. A CC, for example CC3, is set to thenominal bit rate for the CAN system and CT3 is set in a mode where itdoes not actively participate in the communication with transmission,for example Autobaud feedback loop in the case of TI 235. At the SOFsignal in CC3, the value of the clock 409 is captured via 419 and theACK bit is captured via 420 in the clock's capture register 410. Thelength t_(I) of the message is given byt _(I) =T _(s3)+(t _(ACK) −t _(s))+9*T _(b3)

where

-   -   T_(s3) sampling time in CC3    -   t_(ACK) the clock's time at the ACK bit    -   t_(s) the clock's time at the sample point in SOF    -   T_(b3) the bit time according to CC3

The number of stuffing bits can be calculated after reception byapplying the rules of the CAN protocol and hence also the total numberof bits B in the message. As the time stamping was carried out at thefalling edge of the ACK bit and this is followed by 8 bits, the bit rateT_(b) of the transmitting module can be determined with great precisionbyT _(b) =[T _(s3)+(t _(ACK) −t _(s))]/(B−9)

FIG. 9 shows one of several alternative hardware constructions. One ormore CCs are connected to a change-over unit 901 that is controlled bythe CPU 405″ via the connection 902. The CPU can switch the TXconnection from the respective CC from connection to TX4 to CC's owninput RX, to a different CC's RX, to a trigger output 903 connected tosuitable target, for example a capture register or CC's mode switching,or can disconnect it completely. The respective CC's RX connection canbe connected to RX4, to one or more other CCs' TX or can be disconnectedcompletely. In this way, different configurations for different purposescan be achieved in a simple way. In addition, CCs with differentcharacteristics can be connected in parallel, which can be advantageous.For example, MCP2515 can generate an SOF signal, a characteristic thatthe internal CCs in the microprocessor M16C from Mitsubishi does notpossess. The latter has an advanced error register whereby conclusionscan be drawn regarding the type of error and where in the message it wasdiscovered, a characteristic that the former CC does not possess. Byconnecting their RX connections jointly to RX4, more information can beobtained concerning a corrupt message on the bus.

Automatic adaptation to current bit rate in a system.

The method for measuring the length of a message as described above canbe utilized for automatic adaptation to the current bit rate in asystem. The length of received messages is measured using a counterconnected to OSC3. The counter is started by SOF and is stopped by ACK.The number of pulses that is thus counted gives the raw length of themessage up to the acknowledgement bit in the pulses. The receivedmessage is converted according to the rules in the CAN protocol so thatthe number of bits up to the acknowledgement bit is obtained and ismultiplied by the number of pulses from OSC3 that result in a bit. Ifthe number of bits is the same, then the module has the correctfrequency in relation to the transmitting module. If the number of itsown pulses is higher, OSC3's frequency is to be reduced and vice versaif the number is lower. By repeating the measuring for messages fromseveral modules in the system prior to correction and by taking anaverage of the result, adaptation can be carried out to a fictitiousaverage bit length in the system. In this way, a module can interactwith other modules in a reliable way, even if its own oscillator haswide tolerances.

This disclosure is not limited to the embodiments described above, butcan be modified within the framework of the following patent claims andinventive concept described above.

1. A device suitable for incorporation as a module in a CAN systemhaving a bus connection, the device comprising: an oscillator thatgenerates a number of different frequencies in response to directionsfrom the microcomputer; a transceiver; and a Controller Area Network(CAN) Controller coupled to the oscillator, wherein the oscillator iscoupled to the bus connection via the transceiver, wherein the CANController is a first CAN Controller, and wherein the device furthercomprises: a second CAN Controller connected to the bus connection andarranged to supply the bus connection with at least one level relatingto zero or one by first directions received from a particularmicrocomputer and a particular oscillator, wherein the first CANController is operably arranged to utilize previously-known informationabout the function or construction of the CAN system and to indicate arelationship between a first bit configuration that essentiallycorresponds to the outgoing level from the second CAN Controller and oneof a plurality of second bit configurations initiated by the first CANController using the number of different frequencies and the previouslyknown information, and wherein the second CAN Controller comprises meansfor providing an indication of a predetermined degree of disparitybetween the first bit configuration and one of the plurality of secondbit configurations.
 2. A device suitable for incorporation as a modulein a CAN system having a bus connection, the device comprising: anoscillator that generates a number of different frequencies in responseto directions from the microcomputer; a transceiver; and a ControllerArea Network (CAN) Controller coupled to the oscillator, and wherein theoscillator is coupled to the bus connection via the transceiver, furthercomprising means for indicating limits for an acceptable first bitconfiguration and comparing between the first bit configuration and anumber of second bit configurations, wherein the CAN Controller is afirst CAN Controller, and wherein the device further comprises: a secondCAN Controller connected to the bus connection and arranged to supplythe bus connection with at least one level relating to zero or one byfirst directions received from a particular microcomputer and aparticular oscillator, wherein the first CAN Controller is operablyarranged to utilize previously-known information about the function orconstruction of the CAN system and to indicate a relationship between afirst bit configuration that essentially corresponds to the outgoinglevel from the second CAN Controller and one of a plurality of secondbit configurations initiated by the first CAN Controller using thenumber of different frequencies and the previously known information.